<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>

	
		<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="Content-Language" content="en-us">

		<title>Django | Model field reference | Django Documentation</title>

		<meta name="ROBOTS" content="ALL">
		<meta http-equiv="imagetoolbar" content="no">
		<meta name="MSSmartTagsPreventParsing" content="true">
		<meta name="Copyright" content="This site's design and contents Copyright (c) 2005  Lawrence Journal-World.">

		<meta name="keywords" content="Python, Django, framework, open-source">
		<meta name="description" content="Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.">

		<link href="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/base.css" rel="stylesheet" type="text/css" media="screen">
		<link href="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/print.css" rel="stylesheet" type="text/css" media="print">
      
  
  <style type="text/css" media="screen">
    #docs-search {
      color: #000;
      float: right;
    }
    #docs-search form {
      font-size: 92%;
      margin: 0;
      padding: 1em 1em 0;
      white-space: nowrap;
    }
    form.search ul {
      list-style: none;
      margin: 0;
      padding: 0;
    }
    form.search li {
      display: inline;
      padding-right: 1em;
    }
    form.search .query {
      width: 18em;
    }
  </style>
  <link rel="stylesheet" href="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/pygments.css" type="text/css">

	</head><body id="documentation" class="default">

	<div id="container">
		<div id="header">
			<h1 id="logo"><a href="http://www.djangoproject.com/"><img src="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/hdr_logo.gif" alt="Django"></a></h1>
			<ul id="nav-global">
				<li id="nav-homepage"><a href="http://www.djangoproject.com/">Home</a></li>
				<li id="nav-download"><a href="http://www.djangoproject.com/download/">Download</a></li>
				<li id="nav-documentation"><a href="http://docs.djangoproject.com/">Documentation</a></li>
				<li id="nav-weblog"><a href="http://www.djangoproject.com/weblog/">Weblog</a></li>
				<li id="nav-community"><a href="http://www.djangoproject.com/community/">Community</a></li>
				<li id="nav-code"><a href="http://code.djangoproject.com/">Code</a></li>
			</ul>
		</div>
		<!-- END Header -->
		<div id="billboard">
  <h2><a href="http://docs.djangoproject.com/en/1.0/">Django documentation</a></h2>
</div>
		<div id="columnwrap">
			
		<div id="content-main">
		


  <h2 class="deck">
  
    This document describes Django version 1.0. For development documentation, 
    <a href="http://docs.djangoproject.com/en/dev/ref/models/fields/">go here</a>.
  
  </h2>
  <div class="section" id="s-module-django.db.models.fields">
<span id="s-ref-models-fields"></span><span id="module-django.db.models.fields"></span><span id="ref-models-fields"></span><h1>Model field reference<a class="headerlink" href="#module-django.db.models.fields" title="Permalink to this headline">¶</a></h1>
<p>This document contains all the gory details about all the <a class="reference internal" href="#field-options">field options</a> and
<a class="reference internal" href="#field-types">field types</a> Django’s got to offer.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">If the built-in fields don’t do the trick, you can easily <a class="reference external" href="http://docs.djangoproject.com/en/1.0/howto/custom-model-fields/#howto-custom-model-fields"><em>write your
own custom model fields</em></a>.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Technically, these models are defined in <tt class="xref docutils literal"><span class="pre">django.db.models.fields</span></tt>, but
for convenience they’re imported into <a title="" class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#module-django.db.models"><tt class="xref docutils literal"><span class="pre">django.db.models</span></tt></a>; the standard
convention is to use <tt class="docutils literal"><span class="pre">from</span> <span class="pre">django.db</span> <span class="pre">import</span> <span class="pre">models</span></tt> and refer to fields as
<tt class="docutils literal"><span class="pre">models.&lt;Foo&gt;Field</span></tt>.</p>
</div>
<div class="section" id="s-field-options">
<span id="s-common-model-field-options"></span><span id="field-options"></span><span id="common-model-field-options"></span><h2>Field options<a class="headerlink" href="#field-options" title="Permalink to this headline">¶</a></h2>
<p>The following arguments are available to all field types. All are optional.</p>
<div class="section" id="s-null">
<span id="null"></span><h3><tt class="docutils literal"><span class="pre">null</span></tt><a class="headerlink" href="#null" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.null">
<!--[django.db.models.Field.null]--><tt class="descclassname">Field.</tt><tt class="descname">null</tt><a class="headerlink" href="#django.db.models.Field.null" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">True</span></tt>, Django will store empty values as <tt class="docutils literal"><span class="pre">NULL</span></tt> in the database. Default
is <tt class="xref docutils literal"><span class="pre">False</span></tt>.</p>
<p>Note that empty string values will always get stored as empty strings, not as
<tt class="docutils literal"><span class="pre">NULL</span></tt>. Only use <tt class="docutils literal"><span class="pre">null=True</span></tt> for non-string fields such as integers,
booleans and dates. For both types of fields, you will also need to set
<tt class="docutils literal"><span class="pre">blank=True</span></tt> if you wish to permit empty values in forms, as the
<a title="django.db.models.Field.null" class="reference internal" href="#django.db.models.Field.null"><tt class="xref docutils literal"><span class="pre">null</span></tt></a> parameter only affects database storage (see
<a title="django.db.models.Field.blank" class="reference internal" href="#django.db.models.Field.blank"><tt class="xref docutils literal"><span class="pre">blank</span></tt></a>).</p>
<p>Avoid using <a title="django.db.models.Field.null" class="reference internal" href="#django.db.models.Field.null"><tt class="xref docutils literal"><span class="pre">null</span></tt></a> on string-based fields such as
<a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> and <a title="django.db.models.TextField" class="reference internal" href="#django.db.models.TextField"><tt class="xref docutils literal"><span class="pre">TextField</span></tt></a> unless you have an excellent reason.
If a string-based field has <tt class="docutils literal"><span class="pre">null=True</span></tt>, that means it has two possible values
for “no data”: <tt class="docutils literal"><span class="pre">NULL</span></tt>, and the empty string. In most cases, it’s redundant to
have two possible values for “no data;” Django convention is to use the empty
string, not <tt class="docutils literal"><span class="pre">NULL</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When using the Oracle database backend, the <tt class="docutils literal"><span class="pre">null=True</span></tt> option will be
coerced for string-based fields that have the empty string as a possible
value, and the value <tt class="docutils literal"><span class="pre">NULL</span></tt> will be stored to denote the empty string.</p>
</div>
</div>
<div class="section" id="s-blank">
<span id="blank"></span><h3><tt class="docutils literal"><span class="pre">blank</span></tt><a class="headerlink" href="#blank" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.blank">
<!--[django.db.models.Field.blank]--><tt class="descclassname">Field.</tt><tt class="descname">blank</tt><a class="headerlink" href="#django.db.models.Field.blank" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">True</span></tt>, the field is allowed to be blank. Default is <tt class="xref docutils literal"><span class="pre">False</span></tt>.</p>
<p>Note that this is different than <a title="django.db.models.Field.null" class="reference internal" href="#django.db.models.Field.null"><tt class="xref docutils literal"><span class="pre">null</span></tt></a>. <a title="django.db.models.Field.null" class="reference internal" href="#django.db.models.Field.null"><tt class="xref docutils literal"><span class="pre">null</span></tt></a> is
purely database-related, whereas <a title="django.db.models.Field.blank" class="reference internal" href="#django.db.models.Field.blank"><tt class="xref docutils literal"><span class="pre">blank</span></tt></a> is validation-related. If
a field has <tt class="docutils literal"><span class="pre">blank=True</span></tt>, validation on Django’s admin site will allow entry
of an empty value. If a field has <tt class="docutils literal"><span class="pre">blank=False</span></tt>, the field will be required.</p>
</div>
<div class="section" id="s-choices">
<span id="choices"></span><h3><tt class="docutils literal"><span class="pre">choices</span></tt><a class="headerlink" href="#choices" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.choices">
<!--[django.db.models.Field.choices]--><tt class="descclassname">Field.</tt><tt class="descname">choices</tt><a class="headerlink" href="#django.db.models.Field.choices" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>An iterable (e.g., a list or tuple) of 2-tuples to use as choices for this
field.</p>
<p>If this is given, Django’s admin will use a select box instead of the standard
text field and will limit choices to the choices given.</p>
<p>A choices list looks like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">YEAR_IN_SCHOOL_CHOICES</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">'FR'</span><span class="p">,</span> <span class="s">'Freshman'</span><span class="p">),</span>
    <span class="p">(</span><span class="s">'SO'</span><span class="p">,</span> <span class="s">'Sophomore'</span><span class="p">),</span>
    <span class="p">(</span><span class="s">'JR'</span><span class="p">,</span> <span class="s">'Junior'</span><span class="p">),</span>
    <span class="p">(</span><span class="s">'SR'</span><span class="p">,</span> <span class="s">'Senior'</span><span class="p">),</span>
    <span class="p">(</span><span class="s">'GR'</span><span class="p">,</span> <span class="s">'Graduate'</span><span class="p">),</span>
<span class="p">)</span>
</pre></div>
</div>
<p>The first element in each tuple is the actual value to be stored. The second
element is the human-readable name for the option.</p>
<p>The choices list can be defined either as part of your model class:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Foo</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">GENDER_CHOICES</span> <span class="o">=</span> <span class="p">(</span>
        <span class="p">(</span><span class="s">'M'</span><span class="p">,</span> <span class="s">'Male'</span><span class="p">),</span>
        <span class="p">(</span><span class="s">'F'</span><span class="p">,</span> <span class="s">'Female'</span><span class="p">),</span>
    <span class="p">)</span>
    <span class="n">gender</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mf">1</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="n">GENDER_CHOICES</span><span class="p">)</span>
</pre></div>
</div>
<p>or outside your model class altogether:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">GENDER_CHOICES</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">'M'</span><span class="p">,</span> <span class="s">'Male'</span><span class="p">),</span>
    <span class="p">(</span><span class="s">'F'</span><span class="p">,</span> <span class="s">'Female'</span><span class="p">),</span>
<span class="p">)</span>
<span class="k">class</span> <span class="nc">Foo</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">gender</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mf">1</span><span class="p">,</span> <span class="n">choices</span><span class="o">=</span><span class="n">GENDER_CHOICES</span><span class="p">)</span>
</pre></div>
</div>
<p>You can also collect your available choices into named groups that can
be used for organizational purposes:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">MEDIA_CHOICES</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">'Audio'</span><span class="p">,</span> <span class="p">(</span>
            <span class="p">(</span><span class="s">'vinyl'</span><span class="p">,</span> <span class="s">'Vinyl'</span><span class="p">),</span>
            <span class="p">(</span><span class="s">'cd'</span><span class="p">,</span> <span class="s">'CD'</span><span class="p">),</span>
        <span class="p">)</span>
    <span class="p">),</span>
    <span class="p">(</span><span class="s">'Video'</span><span class="p">,</span> <span class="p">(</span>
            <span class="p">(</span><span class="s">'vhs'</span><span class="p">,</span> <span class="s">'VHS Tape'</span><span class="p">),</span>
            <span class="p">(</span><span class="s">'dvd'</span><span class="p">,</span> <span class="s">'DVD'</span><span class="p">),</span>
        <span class="p">)</span>
    <span class="p">),</span>
    <span class="p">(</span><span class="s">'unknown'</span><span class="p">,</span> <span class="s">'Unknown'</span><span class="p">),</span>
<span class="p">)</span>
</pre></div>
</div>
<p>The first element in each tuple is the name to apply to the group. The
second element is an iterable of 2-tuples, with each 2-tuple containing
a value and a human-readable name for an option. Grouped options may be
combined with ungrouped options within a single list (such as the
<cite>unknown</cite> option in this example).</p>
<p>For each model field that has <a title="django.db.models.Field.choices" class="reference internal" href="#django.db.models.Field.choices"><tt class="xref docutils literal"><span class="pre">choices</span></tt></a> set, Django will add a
method to retrieve the human-readable name for the field's current value. See
<a title="django.db.models.Model.get_FOO_display" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/models/instances/#django.db.models.Model.get_FOO_display"><tt class="xref docutils literal"><span class="pre">get_FOO_display()</span></tt></a> in the database API
documentation.</p>
<p>Finally, note that choices can be any iterable object -- not necessarily a list
or tuple. This lets you construct choices dynamically. But if you find yourself
hacking <a title="django.db.models.Field.choices" class="reference internal" href="#django.db.models.Field.choices"><tt class="xref docutils literal"><span class="pre">choices</span></tt></a> to be dynamic, you're probably better off using a
proper database table with a <a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a>. <a title="django.db.models.Field.choices" class="reference internal" href="#django.db.models.Field.choices"><tt class="xref docutils literal"><span class="pre">choices</span></tt></a> is
meant for static data that doesn't change much, if ever.</p>
</div>
<div class="section" id="s-db-column">
<span id="db-column"></span><h3><tt class="docutils literal"><span class="pre">db_column</span></tt><a class="headerlink" href="#db-column" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.db_column">
<!--[django.db.models.Field.db_column]--><tt class="descclassname">Field.</tt><tt class="descname">db_column</tt><a class="headerlink" href="#django.db.models.Field.db_column" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The name of the database column to use for this field. If this isn't given,
Django will use the field's name.</p>
<p>If your database column name is an SQL reserved word, or contains
characters that aren't allowed in Python variable names -- notably, the
hyphen -- that's OK. Django quotes column and table names behind the
scenes.</p>
</div>
<div class="section" id="s-db-index">
<span id="db-index"></span><h3><tt class="docutils literal"><span class="pre">db_index</span></tt><a class="headerlink" href="#db-index" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.db_index">
<!--[django.db.models.Field.db_index]--><tt class="descclassname">Field.</tt><tt class="descname">db_index</tt><a class="headerlink" href="#django.db.models.Field.db_index" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">True</span></tt>, djadmin:<cite>django-admin.py sqlindexes &lt;sqlindexes&gt;</cite> will output a
<tt class="docutils literal"><span class="pre">CREATE</span> <span class="pre">INDEX</span></tt> statement for this field.</p>
</div>
<div class="section" id="s-db-tablespace">
<span id="db-tablespace"></span><h3><tt class="docutils literal"><span class="pre">db_tablespace</span></tt><a class="headerlink" href="#db-tablespace" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.db_tablespace">
<!--[django.db.models.Field.db_tablespace]--><tt class="descclassname">Field.</tt><tt class="descname">db_tablespace</tt><a class="headerlink" href="#django.db.models.Field.db_tablespace" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionadded">
<span class="title">New in Django 1.0:</span> <a class="reference external" href="http://docs.djangoproject.com/en/1.0/releases/1.0/#releases-1-0"><em>Please, see the release notes</em></a></div>
<p>The name of the database tablespace to use for this field's index, if this field
is indexed. The default is the project's <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-DEFAULT_INDEX_TABLESPACE"><tt class="xref docutils literal"><span class="pre">DEFAULT_INDEX_TABLESPACE</span></tt></a>
setting, if set, or the <a title="django.db.models.Field.db_tablespace" class="reference internal" href="#django.db.models.Field.db_tablespace"><tt class="xref docutils literal"><span class="pre">db_tablespace</span></tt></a> of the model, if any. If
the backend doesn't support tablespaces, this option is ignored.</p>
</div>
<div class="section" id="s-default">
<span id="default"></span><h3><tt class="docutils literal"><span class="pre">default</span></tt><a class="headerlink" href="#default" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.default">
<!--[django.db.models.Field.default]--><tt class="descclassname">Field.</tt><tt class="descname">default</tt><a class="headerlink" href="#django.db.models.Field.default" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The default value for the field. This can be a value or a callable object. If
callable it will be called every time a new object is created.</p>
</div>
<div class="section" id="s-editable">
<span id="editable"></span><h3><tt class="docutils literal"><span class="pre">editable</span></tt><a class="headerlink" href="#editable" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.editable">
<!--[django.db.models.Field.editable]--><tt class="descclassname">Field.</tt><tt class="descname">editable</tt><a class="headerlink" href="#django.db.models.Field.editable" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">False</span></tt>, the field will not be editable in the admin or via forms
automatically generated from the model class. Default is <tt class="xref docutils literal"><span class="pre">True</span></tt>.</p>
</div>
<div class="section" id="s-help-text">
<span id="help-text"></span><h3><tt class="docutils literal"><span class="pre">help_text</span></tt><a class="headerlink" href="#help-text" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.help_text">
<!--[django.db.models.Field.help_text]--><tt class="descclassname">Field.</tt><tt class="descname">help_text</tt><a class="headerlink" href="#django.db.models.Field.help_text" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Extra "help" text to be displayed under the field on the object's admin form.
It's useful for documentation even if your object doesn't have an admin form.</p>
<p>Note that this value is <em>not</em> HTML-escaped when it's displayed in the admin
interface. This lets you include HTML in <a title="django.db.models.Field.help_text" class="reference internal" href="#django.db.models.Field.help_text"><tt class="xref docutils literal"><span class="pre">help_text</span></tt></a> if you so
desire. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">help_text</span><span class="o">=</span><span class="s">"Please use the following format: &lt;em&gt;YYYY-MM-DD&lt;/em&gt;."</span>
</pre></div>
</div>
<p>Alternatively you can use plain text and
<tt class="docutils literal"><span class="pre">django.utils.html.escape()</span></tt> to escape any HTML special characters.</p>
</div>
<div class="section" id="s-primary-key">
<span id="primary-key"></span><h3><tt class="docutils literal"><span class="pre">primary_key</span></tt><a class="headerlink" href="#primary-key" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.primary_key">
<!--[django.db.models.Field.primary_key]--><tt class="descclassname">Field.</tt><tt class="descname">primary_key</tt><a class="headerlink" href="#django.db.models.Field.primary_key" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">True</span></tt>, this field is the primary key for the model.</p>
<p>If you don't specify <tt class="docutils literal"><span class="pre">primary_key=True</span></tt> for any fields in your model, Django
will automatically add an <a title="django.db.models.IntegerField" class="reference internal" href="#django.db.models.IntegerField"><tt class="xref docutils literal"><span class="pre">IntegerField</span></tt></a> to hold the primary key, so you
don't need to set <tt class="docutils literal"><span class="pre">primary_key=True</span></tt> on any of your fields unless you want to
override the default primary-key behavior. For more, see
<a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#automatic-primary-key-fields"><em>Automatic primary key fields</em></a>.</p>
<p><tt class="docutils literal"><span class="pre">primary_key=True</span></tt> implies <a title="django.db.models.Field.null" class="reference internal" href="#django.db.models.Field.null"><tt class="xref docutils literal"><span class="pre">null=False</span></tt></a> and <a title="django.db.models.Field.unique" class="reference internal" href="#django.db.models.Field.unique"><tt class="xref docutils literal"><span class="pre">unique=True</span></tt></a>.
Only one primary key is allowed on an object.</p>
</div>
<div class="section" id="s-unique">
<span id="unique"></span><h3><tt class="docutils literal"><span class="pre">unique</span></tt><a class="headerlink" href="#unique" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.unique">
<!--[django.db.models.Field.unique]--><tt class="descclassname">Field.</tt><tt class="descname">unique</tt><a class="headerlink" href="#django.db.models.Field.unique" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>If <tt class="xref docutils literal"><span class="pre">True</span></tt>, this field must be unique throughout the table.</p>
<p>This is enforced at the database level and at the Django admin-form level. If
you try to save a model with a duplicate value in a <a title="django.db.models.Field.unique" class="reference internal" href="#django.db.models.Field.unique"><tt class="xref docutils literal"><span class="pre">unique</span></tt></a>
field, a <tt class="xref docutils literal"><span class="pre">django.db.IntegrityError</span></tt> will be raised by the model's
<a title="django.db.models.Model.save" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/models/instances/#django.db.models.Model.save"><tt class="xref docutils literal"><span class="pre">save()</span></tt></a> method.</p>
<p>This option is valid on all field types except <a title="django.db.models.ManyToManyField" class="reference internal" href="#django.db.models.ManyToManyField"><tt class="xref docutils literal"><span class="pre">ManyToManyField</span></tt></a> and
<a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a>.</p>
</div>
<div class="section" id="s-unique-for-date">
<span id="unique-for-date"></span><h3><tt class="docutils literal"><span class="pre">unique_for_date</span></tt><a class="headerlink" href="#unique-for-date" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.unique_for_date">
<!--[django.db.models.Field.unique_for_date]--><tt class="descclassname">Field.</tt><tt class="descname">unique_for_date</tt><a class="headerlink" href="#django.db.models.Field.unique_for_date" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Set this to the name of a <a title="django.db.models.DateField" class="reference internal" href="#django.db.models.DateField"><tt class="xref docutils literal"><span class="pre">DateField</span></tt></a> or <a title="django.db.models.DateTimeField" class="reference internal" href="#django.db.models.DateTimeField"><tt class="xref docutils literal"><span class="pre">DateTimeField</span></tt></a> to
require that this field be unique for the value of the date field.</p>
<p>For example, if you have a field <tt class="docutils literal"><span class="pre">title</span></tt> that has
<tt class="docutils literal"><span class="pre">unique_for_date="pub_date"</span></tt>, then Django wouldn't allow the entry of two
records with the same <tt class="docutils literal"><span class="pre">title</span></tt> and <tt class="docutils literal"><span class="pre">pub_date</span></tt>.</p>
<p>This is enforced at the Django admin-form level but not at the database level.</p>
</div>
<div class="section" id="s-unique-for-month">
<span id="unique-for-month"></span><h3><tt class="docutils literal"><span class="pre">unique_for_month</span></tt><a class="headerlink" href="#unique-for-month" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.unique_for_month">
<!--[django.db.models.Field.unique_for_month]--><tt class="descclassname">Field.</tt><tt class="descname">unique_for_month</tt><a class="headerlink" href="#django.db.models.Field.unique_for_month" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like <a title="django.db.models.Field.unique_for_date" class="reference internal" href="#django.db.models.Field.unique_for_date"><tt class="xref docutils literal"><span class="pre">unique_for_date</span></tt></a>, but requires the field to be unique with
respect to the month.</p>
</div>
<div class="section" id="s-unique-for-year">
<span id="unique-for-year"></span><h3><tt class="docutils literal"><span class="pre">unique_for_year</span></tt><a class="headerlink" href="#unique-for-year" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.unique_for_year">
<!--[django.db.models.Field.unique_for_year]--><tt class="descclassname">Field.</tt><tt class="descname">unique_for_year</tt><a class="headerlink" href="#django.db.models.Field.unique_for_year" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like <a title="django.db.models.Field.unique_for_date" class="reference internal" href="#django.db.models.Field.unique_for_date"><tt class="xref docutils literal"><span class="pre">unique_for_date</span></tt></a> and <a title="django.db.models.Field.unique_for_month" class="reference internal" href="#django.db.models.Field.unique_for_month"><tt class="xref docutils literal"><span class="pre">unique_for_month</span></tt></a>.</p>
</div>
<div class="section" id="s-verbose-name">
<span id="verbose-name"></span><h3><tt class="docutils literal"><span class="pre">verbose_name</span></tt><a class="headerlink" href="#verbose-name" title="Permalink to this headline">¶</a></h3>
<dl class="attribute">
<dt id="django.db.models.Field.verbose_name">
<!--[django.db.models.Field.verbose_name]--><tt class="descclassname">Field.</tt><tt class="descname">verbose_name</tt><a class="headerlink" href="#django.db.models.Field.verbose_name" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A human-readable name for the field. If the verbose name isn't given, Django
will automatically create it using the field's attribute name, converting
underscores to spaces. See <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#verbose-field-names"><em>Verbose field names</em></a>.</p>
</div>
</div>
<div class="section" id="s-field-types">
<span id="s-model-field-types"></span><span id="field-types"></span><span id="model-field-types"></span><h2>Field types<a class="headerlink" href="#field-types" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-autofield">
<span id="autofield"></span><h3><tt class="docutils literal"><span class="pre">AutoField</span></tt><a class="headerlink" href="#autofield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.AutoField">
<!--[django.db.models.AutoField]-->class <tt class="descname">AutoField</tt>(<em>**options</em>)<a class="headerlink" href="#django.db.models.AutoField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>An <a title="django.db.models.IntegerField" class="reference internal" href="#django.db.models.IntegerField"><tt class="xref docutils literal"><span class="pre">IntegerField</span></tt></a> that automatically increments
according to available IDs. You usually won't need to use this directly; a
primary key field will automatically be added to your model if you don't specify
otherwise. See <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#automatic-primary-key-fields"><em>Automatic primary key fields</em></a>.</p>
</div>
<div class="section" id="s-booleanfield">
<span id="booleanfield"></span><h3><tt class="docutils literal"><span class="pre">BooleanField</span></tt><a class="headerlink" href="#booleanfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.BooleanField">
<!--[django.db.models.BooleanField]-->class <tt class="descname">BooleanField</tt>(<em>**options</em>)<a class="headerlink" href="#django.db.models.BooleanField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A true/false field.</p>
<p>The admin represents this as a checkbox.</p>
<div class="admonition-mysql-users admonition">
<p class="first admonition-title">MySQL users..</p>
<p class="last">A boolean field in MySQL is stored as a <tt class="docutils literal"><span class="pre">TINYINT</span></tt> column with a value of
either 0 or 1 (most databases have a proper <tt class="docutils literal"><span class="pre">BOOLEAN</span></tt> type instead). So,
for MySQL, only, when a <tt class="docutils literal"><span class="pre">BooleanField</span></tt> is retrieved from the database
and stored on a model attribute, it will have the values 1 or 0, rather
than <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt>. Normally, this shouldn't be a problem, since
Python guarantees that <tt class="docutils literal"><span class="pre">1</span> <span class="pre">==</span> <span class="pre">True</span></tt> and <tt class="docutils literal"><span class="pre">0</span> <span class="pre">==</span> <span class="pre">False</span></tt> are both true.
Just be careful if you're writing something like <tt class="docutils literal"><span class="pre">obj</span> <span class="pre">is</span> <span class="pre">True</span></tt> when
<tt class="docutils literal"><span class="pre">obj</span></tt> is a value from a boolean attribute on a model. If that model was
constructed using the <tt class="docutils literal"><span class="pre">mysql</span></tt> backend, the "<tt class="docutils literal"><span class="pre">is</span></tt>" test will fail.
Prefer an equality test (using "<tt class="docutils literal"><span class="pre">==</span></tt>") in cases like this.</p>
</div>
</div>
<div class="section" id="s-charfield">
<span id="charfield"></span><h3><tt class="docutils literal"><span class="pre">CharField</span></tt><a class="headerlink" href="#charfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.CharField">
<!--[django.db.models.CharField]-->class <tt class="descname">CharField</tt>(<em>max_length=None</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.CharField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A string field, for small- to large-sized strings.</p>
<p>For large amounts of text, use <a title="django.db.models.TextField" class="reference internal" href="#django.db.models.TextField"><tt class="xref docutils literal"><span class="pre">TextField</span></tt></a>.</p>
<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a single-line input).</p>
<p><a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> has one extra required argument:</p>
<dl class="attribute">
<dt id="django.db.models.CharField.max_length">
<!--[django.db.models.CharField.max_length]--><tt class="descclassname">CharField.</tt><tt class="descname">max_length</tt><a class="headerlink" href="#django.db.models.CharField.max_length" title="Permalink to this definition">¶</a></dt>
<dd>The maximum length (in characters) of the field. The max_length is enforced
at the database level and in Django's validation.</dd></dl>

<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you are writing an application that must be portable to multiple
database backends, you should be aware that there are restrictions on
<tt class="docutils literal"><span class="pre">max_length</span></tt> for some backends. Refer to the <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/databases/#ref-databases"><em>database backend
notes</em></a> for details.</p>
</div>
<div class="admonition-mysql-users admonition">
<p class="first admonition-title">MySQL users</p>
<p class="last">If you are using this field with MySQLdb 1.2.2 and the <tt class="docutils literal"><span class="pre">utf8_bin</span></tt>
collation (which is <em>not</em> the default), there are some issues to be aware
of. Refer to the <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/databases/#mysql-collation"><em>MySQL database notes</em></a> for
details.</p>
</div>
</div>
<div class="section" id="s-commaseparatedintegerfield">
<span id="commaseparatedintegerfield"></span><h3><tt class="docutils literal"><span class="pre">CommaSeparatedIntegerField</span></tt><a class="headerlink" href="#commaseparatedintegerfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.CommaSeparatedIntegerField">
<!--[django.db.models.CommaSeparatedIntegerField]-->class <tt class="descname">CommaSeparatedIntegerField</tt>(<em>max_length=None</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.CommaSeparatedIntegerField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A field of integers separated by commas. As in <a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a>, the
<a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> argument is required and the note about database
portability mentioned there should be heeded.</p>
</div>
<div class="section" id="s-datefield">
<span id="datefield"></span><h3><tt class="docutils literal"><span class="pre">DateField</span></tt><a class="headerlink" href="#datefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.DateField">
<!--[django.db.models.DateField]-->class <tt class="descname">DateField</tt>(<span class="optional">[</span><em>auto_now=False</em>, <em>auto_now_add=False</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.DateField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A date, represented in Python by a <tt class="docutils literal"><span class="pre">datetime.date</span></tt> instance. Has a few extra,
optional arguments:</p>
<dl class="attribute">
<dt id="django.db.models.DateField.auto_now">
<!--[django.db.models.DateField.auto_now]--><tt class="descclassname">DateField.</tt><tt class="descname">auto_now</tt><a class="headerlink" href="#django.db.models.DateField.auto_now" title="Permalink to this definition">¶</a></dt>
<dd>Automatically set the field to now every time the object is saved. Useful
for "last-modified" timestamps. Note that the current date is <em>always</em>
used; it's not just a default value that you can override.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.DateField.auto_now_add">
<!--[django.db.models.DateField.auto_now_add]--><tt class="descclassname">DateField.</tt><tt class="descname">auto_now_add</tt><a class="headerlink" href="#django.db.models.DateField.auto_now_add" title="Permalink to this definition">¶</a></dt>
<dd>Automatically set the field to now when the object is first created. Useful
for creation of timestamps. Note that the current date is <em>always</em> used;
it's not just a default value that you can override.</dd></dl>

<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> with a JavaScript
calendar, and a shortcut for "Today".  The JavaScript calendar will always
start the week on a Sunday.</p>
</div>
<div class="section" id="s-datetimefield">
<span id="datetimefield"></span><h3><tt class="docutils literal"><span class="pre">DateTimeField</span></tt><a class="headerlink" href="#datetimefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.DateTimeField">
<!--[django.db.models.DateTimeField]-->class <tt class="descname">DateTimeField</tt>(<span class="optional">[</span><em>auto_now=False</em>, <em>auto_now_add=False</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.DateTimeField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A date and time, represented in Python by a <tt class="docutils literal"><span class="pre">datetime.datetime</span></tt> instance.
Takes the same extra arguments as <a title="django.db.models.DateField" class="reference internal" href="#django.db.models.DateField"><tt class="xref docutils literal"><span class="pre">DateField</span></tt></a>.</p>
<p>The admin represents this as two <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> fields, with
JavaScript shortcuts.</p>
</div>
<div class="section" id="s-decimalfield">
<span id="decimalfield"></span><h3><tt class="docutils literal"><span class="pre">DecimalField</span></tt><a class="headerlink" href="#decimalfield" title="Permalink to this headline">¶</a></h3>
<div class="versionadded">
<span class="title">New in Django 1.0:</span> <a class="reference external" href="http://docs.djangoproject.com/en/1.0/releases/1.0/#releases-1-0"><em>Please, see the release notes</em></a></div>
<dl class="class">
<dt id="django.db.models.DecimalField">
<!--[django.db.models.DecimalField]-->class <tt class="descname">DecimalField</tt>(<em>max_digits=None</em>, <em>decimal_places=None</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.DecimalField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A fixed-precision decimal number, represented in Python by a
<tt class="xref docutils literal"><span class="pre">Decimal</span></tt> instance. Has two <strong>required</strong> arguments:</p>
<dl class="attribute">
<dt id="django.db.models.DecimalField.max_digits">
<!--[django.db.models.DecimalField.max_digits]--><tt class="descclassname">DecimalField.</tt><tt class="descname">max_digits</tt><a class="headerlink" href="#django.db.models.DecimalField.max_digits" title="Permalink to this definition">¶</a></dt>
<dd>The maximum number of digits allowed in the number</dd></dl>

<dl class="attribute">
<dt id="django.db.models.DecimalField.decimal_places">
<!--[django.db.models.DecimalField.decimal_places]--><tt class="descclassname">DecimalField.</tt><tt class="descname">decimal_places</tt><a class="headerlink" href="#django.db.models.DecimalField.decimal_places" title="Permalink to this definition">¶</a></dt>
<dd>The number of decimal places to store with the number</dd></dl>

<p>For example, to store numbers up to 999 with a resolution of 2 decimal places,
you'd use:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">models</span><span class="o">.</span><span class="n">DecimalField</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">max_digits</span><span class="o">=</span><span class="mf">5</span><span class="p">,</span> <span class="n">decimal_places</span><span class="o">=</span><span class="mf">2</span><span class="p">)</span>
</pre></div>
</div>
<p>And to store numbers up to approximately one billion with a resolution of 10
decimal places:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">models</span><span class="o">.</span><span class="n">DecimalField</span><span class="p">(</span><span class="o">...</span><span class="p">,</span> <span class="n">max_digits</span><span class="o">=</span><span class="mf">19</span><span class="p">,</span> <span class="n">decimal_places</span><span class="o">=</span><span class="mf">10</span><span class="p">)</span>
</pre></div>
</div>
<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a single-line input).</p>
</div>
<div class="section" id="s-emailfield">
<span id="emailfield"></span><h3><tt class="docutils literal"><span class="pre">EmailField</span></tt><a class="headerlink" href="#emailfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.EmailField">
<!--[django.db.models.EmailField]-->class <tt class="descname">EmailField</tt>(<span class="optional">[</span><em>max_length=75</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.EmailField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A <a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> that checks that the value is a valid e-mail address.</p>
</div>
<div class="section" id="s-filefield">
<span id="filefield"></span><h3><tt class="docutils literal"><span class="pre">FileField</span></tt><a class="headerlink" href="#filefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.FileField">
<!--[django.db.models.FileField]-->class <tt class="descname">FileField</tt>(<em>upload_to=None</em><span class="optional">[</span>, <em>max_length=100</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.FileField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A file-upload field.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <tt class="docutils literal"><span class="pre">primary_key</span></tt> and <tt class="docutils literal"><span class="pre">unique</span></tt> arguments are not supported, and will
raise a <tt class="docutils literal"><span class="pre">TypeError</span></tt> if used.</p>
</div>
<p>Has one <strong>required</strong> argument:</p>
<dl class="attribute">
<dt id="django.db.models.FileField.upload_to">
<!--[django.db.models.FileField.upload_to]--><tt class="descclassname">FileField.</tt><tt class="descname">upload_to</tt><a class="headerlink" href="#django.db.models.FileField.upload_to" title="Permalink to this definition">¶</a></dt>
<dd><p>A local filesystem path that will be appended to your <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_ROOT"><tt class="xref docutils literal"><span class="pre">MEDIA_ROOT</span></tt></a>
setting to determine the value of the <a title="django.core.files.File.url" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/files/file/#django.core.files.File.url"><tt class="xref docutils literal"><span class="pre">url</span></tt></a>
attribute.</p>
<p>This path may contain <a class="reference external" href="http://docs.python.org/lib/module-time.html#l2h-1941">strftime formatting</a>, which will be replaced by the
date/time of the file upload (so that uploaded files don't fill up the given
directory).</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.0:</span> <a class="reference external" href="http://docs.djangoproject.com/en/1.0/releases/1.0/#releases-1-0"><em>Please, see the release notes</em></a></div>
<p>This may also be a callable, such as a function, which will be called to
obtain the upload path, including the filename. This callable must be able
to accept two arguments, and return a Unix-style path (with forward slashes)
to be passed along to the storage system. The two arguments that will be
passed are:</p>
<table class="docutils">
<colgroup>
<col width="32%">
<col width="68%">
</colgroup>
<thead valign="bottom">
<tr><th class="head">Argument</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">instance</span></tt></td>
<td><p class="first">An instance of the model where the
<tt class="docutils literal"><span class="pre">FileField</span></tt> is defined. More specifically,
this is the particular instance where the
current file is being attached.</p>
<p class="last">In most cases, this object will not have been
saved to the database yet, so if it uses the
default <tt class="docutils literal"><span class="pre">AutoField</span></tt>, <em>it might not yet have a
value for its primary key field</em>.</p>
</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">filename</span></tt></td>
<td>The filename that was originally given to the
file. This may or may not be taken into account
when determining the final destination path.</td>
</tr>
</tbody>
</table>
</dd></dl>

<p>Also has one optional argument:</p>
<dl class="attribute">
<dt id="django.db.models.FileField.storage">
<!--[django.db.models.FileField.storage]--><tt class="descclassname">FileField.</tt><tt class="descname">storage</tt><a class="headerlink" href="#django.db.models.FileField.storage" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.0:</span> <a class="reference external" href="http://docs.djangoproject.com/en/1.0/releases/1.0/#releases-1-0"><em>Please, see the release notes</em></a></div>
<p>Optional. A storage object, which handles the storage and retrieval of your
files. See <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/files/#topics-files"><em>Managing files</em></a> for details on how to provide this object.</p>
</dd></dl>

<p>The admin represents this field as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="file"&gt;</span></tt> (a file-upload
widget).</p>
<p>Using a <a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a> or an <a title="django.db.models.ImageField" class="reference internal" href="#django.db.models.ImageField"><tt class="xref docutils literal"><span class="pre">ImageField</span></tt></a> (see below) in a model
takes a few steps:</p>
<ol class="arabic simple">
<li>In your settings file, you'll need to define <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_ROOT"><tt class="xref docutils literal"><span class="pre">MEDIA_ROOT</span></tt></a> as the
full path to a directory where you'd like Django to store uploaded files.
(For performance, these files are not stored in the database.) Define
<a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_URL"><tt class="xref docutils literal"><span class="pre">MEDIA_URL</span></tt></a> as the base public URL of that directory. Make sure
that this directory is writable by the Web server's user account.</li>
<li>Add the <a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a> or <a title="django.db.models.ImageField" class="reference internal" href="#django.db.models.ImageField"><tt class="xref docutils literal"><span class="pre">ImageField</span></tt></a> to your model, making
sure to define the <a title="django.db.models.FileField.upload_to" class="reference internal" href="#django.db.models.FileField.upload_to"><tt class="xref docutils literal"><span class="pre">upload_to</span></tt></a> option to tell Django
to which subdirectory of <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_ROOT"><tt class="xref docutils literal"><span class="pre">MEDIA_ROOT</span></tt></a> it should upload files.</li>
<li>All that will be stored in your database is a path to the file
(relative to <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_ROOT"><tt class="xref docutils literal"><span class="pre">MEDIA_ROOT</span></tt></a>). You'll most likely want to use the
convenience <a title="django.core.files.File.url" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/files/file/#django.core.files.File.url"><tt class="xref docutils literal"><span class="pre">url</span></tt></a> function provided by
Django. For example, if your <a title="django.db.models.ImageField" class="reference internal" href="#django.db.models.ImageField"><tt class="xref docutils literal"><span class="pre">ImageField</span></tt></a> is called <tt class="docutils literal"><span class="pre">mug_shot</span></tt>,
you can get the absolute URL to your image in a template with
<tt class="docutils literal"><span class="pre">{{</span> <span class="pre">object.mug_shot.url</span> <span class="pre">}}</span></tt>.</li>
</ol>
<p>For example, say your <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/settings/#setting-MEDIA_ROOT"><tt class="xref docutils literal"><span class="pre">MEDIA_ROOT</span></tt></a> is set to <tt class="docutils literal"><span class="pre">'/home/media'</span></tt>, and
<a title="django.db.models.FileField.upload_to" class="reference internal" href="#django.db.models.FileField.upload_to"><tt class="xref docutils literal"><span class="pre">upload_to</span></tt></a> is set to <tt class="docutils literal"><span class="pre">'photos/%Y/%m/%d'</span></tt>. The <tt class="docutils literal"><span class="pre">'%Y/%m/%d'</span></tt>
part of <a title="django.db.models.FileField.upload_to" class="reference internal" href="#django.db.models.FileField.upload_to"><tt class="xref docutils literal"><span class="pre">upload_to</span></tt></a> is <a class="reference external" href="http://docs.python.org/lib/module-time.html#l2h-1941">strftime formatting</a>; <tt class="docutils literal"><span class="pre">'%Y'</span></tt> is the
four-digit year, <tt class="docutils literal"><span class="pre">'%m'</span></tt> is the two-digit month and <tt class="docutils literal"><span class="pre">'%d'</span></tt> is the two-digit
day. If you upload a file on Jan. 15, 2007, it will be saved in the directory
<tt class="docutils literal"><span class="pre">/home/media/photos/2007/01/15</span></tt>.</p>
<p>If you want to retrieve the upload file's on-disk filename, or a URL that refers
to that file, or the file's size, you can use the
<a title="django.core.files.File.name" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/files/file/#django.core.files.File.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a>, <a title="django.core.files.File.url" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/files/file/#django.core.files.File.url"><tt class="xref docutils literal"><span class="pre">url</span></tt></a>
and <a title="django.core.files.File.size" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/files/file/#django.core.files.File.size"><tt class="xref docutils literal"><span class="pre">size</span></tt></a> attributes; see <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/files/#topics-files"><em>Managing files</em></a>.</p>
<p>Note that whenever you deal with uploaded files, you should pay close attention
to where you're uploading them and what type of files they are, to avoid
security holes. <em>Validate all uploaded files</em> so that you're sure the files are
what you think they are. For example, if you blindly let somebody upload files,
without validation, to a directory that's within your Web server's document
root, then somebody could upload a CGI or PHP script and execute that script by
visiting its URL on your site. Don't allow that.</p>
<div class="versionadded">
<span class="title">New in Django 1.0:</span> The <tt class="docutils literal"><span class="pre">max_length</span></tt> argument was added in this version.</div>
<p>By default, <a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a> instances are
created as <tt class="docutils literal"><span class="pre">varchar(100)</span></tt> columns in your database. As with other fields, you
can change the maximum length using the <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> argument.</p>
</div>
<div class="section" id="s-filepathfield">
<span id="filepathfield"></span><h3><tt class="docutils literal"><span class="pre">FilePathField</span></tt><a class="headerlink" href="#filepathfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.FilePathField">
<!--[django.db.models.FilePathField]-->class <tt class="descname">FilePathField</tt>(<em>path=None</em><span class="optional">[</span>, <em>match=None</em>, <em>recursive=False</em>, <em>max_length=100</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.FilePathField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A <a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> whose choices are limited to the filenames in a certain
directory on the filesystem. Has three special arguments, of which the first is
<strong>required</strong>:</p>
<dl class="attribute">
<dt id="django.db.models.FilePathField.path">
<!--[django.db.models.FilePathField.path]--><tt class="descclassname">FilePathField.</tt><tt class="descname">path</tt><a class="headerlink" href="#django.db.models.FilePathField.path" title="Permalink to this definition">¶</a></dt>
<dd>Required. The absolute filesystem path to a directory from which this
<a title="django.db.models.FilePathField" class="reference internal" href="#django.db.models.FilePathField"><tt class="xref docutils literal"><span class="pre">FilePathField</span></tt></a> should get its choices. Example: <tt class="docutils literal"><span class="pre">"/home/images"</span></tt>.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.FilePathField.match">
<!--[django.db.models.FilePathField.match]--><tt class="descclassname">FilePathField.</tt><tt class="descname">match</tt><a class="headerlink" href="#django.db.models.FilePathField.match" title="Permalink to this definition">¶</a></dt>
<dd>Optional. A regular expression, as a string, that <a title="django.db.models.FilePathField" class="reference internal" href="#django.db.models.FilePathField"><tt class="xref docutils literal"><span class="pre">FilePathField</span></tt></a>
will use to filter filenames. Note that the regex will be applied to the
base filename, not the full path. Example: <tt class="docutils literal"><span class="pre">"foo.*\.txt$"</span></tt>, which will
match a file called <tt class="docutils literal"><span class="pre">foo23.txt</span></tt> but not <tt class="docutils literal"><span class="pre">bar.txt</span></tt> or <tt class="docutils literal"><span class="pre">foo23.gif</span></tt>.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.FilePathField.recursive">
<!--[django.db.models.FilePathField.recursive]--><tt class="descclassname">FilePathField.</tt><tt class="descname">recursive</tt><a class="headerlink" href="#django.db.models.FilePathField.recursive" title="Permalink to this definition">¶</a></dt>
<dd>Optional. Either <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt>. Default is <tt class="xref docutils literal"><span class="pre">False</span></tt>. Specifies
whether all subdirectories of <a title="django.db.models.FilePathField.path" class="reference internal" href="#django.db.models.FilePathField.path"><tt class="xref docutils literal"><span class="pre">path</span></tt></a> should be included</dd></dl>

<p>Of course, these arguments can be used together.</p>
<p>The one potential gotcha is that <a title="django.db.models.FilePathField.match" class="reference internal" href="#django.db.models.FilePathField.match"><tt class="xref docutils literal"><span class="pre">match</span></tt></a> applies to the
base filename, not the full path. So, this example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">FilePathField</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="s">"/home/images"</span><span class="p">,</span> <span class="n">match</span><span class="o">=</span><span class="s">"foo.*"</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</pre></div>
</div>
<p>...will match <tt class="docutils literal"><span class="pre">/home/images/foo.gif</span></tt> but not <tt class="docutils literal"><span class="pre">/home/images/foo/bar.gif</span></tt>
because the <a title="django.db.models.FilePathField.match" class="reference internal" href="#django.db.models.FilePathField.match"><tt class="xref docutils literal"><span class="pre">match</span></tt></a> applies to the base filename
(<tt class="docutils literal"><span class="pre">foo.gif</span></tt> and <tt class="docutils literal"><span class="pre">bar.gif</span></tt>).</p>
<div class="versionadded">
<span class="title">New in Django 1.0:</span> The <tt class="docutils literal"><span class="pre">max_length</span></tt> argument was added in this version.</div>
<p>By default, <a title="django.db.models.FilePathField" class="reference internal" href="#django.db.models.FilePathField"><tt class="xref docutils literal"><span class="pre">FilePathField</span></tt></a> instances are
created as <tt class="docutils literal"><span class="pre">varchar(100)</span></tt> columns in your database. As with other fields, you
can change the maximum length using the <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> argument.</p>
</div>
<div class="section" id="s-floatfield">
<span id="floatfield"></span><h3><tt class="docutils literal"><span class="pre">FloatField</span></tt><a class="headerlink" href="#floatfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.FloatField">
<!--[django.db.models.FloatField]-->class <tt class="descname">FloatField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.FloatField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<div class="versionchanged">
<span class="title">Changed in Django 1.0:</span> <a class="reference external" href="http://docs.djangoproject.com/en/1.0/releases/1.0/#releases-1-0"><em>Please, see the release notes</em></a></div>
<p>A floating-point number represented in Python by a <tt class="docutils literal"><span class="pre">float</span></tt> instance.</p>
<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a single-line input).</p>
</div>
<div class="section" id="s-imagefield">
<span id="imagefield"></span><h3><tt class="docutils literal"><span class="pre">ImageField</span></tt><a class="headerlink" href="#imagefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.ImageField">
<!--[django.db.models.ImageField]-->class <tt class="descname">ImageField</tt>(<em>upload_to=None</em><span class="optional">[</span>, <em>height_field=None</em>, <em>width_field=None</em>, <em>max_length=100</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.ImageField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like <a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a>, but validates that the uploaded object is a valid
image. Has two extra optional arguments:</p>
<dl class="attribute">
<dt id="django.db.models.ImageField.height_field">
<!--[django.db.models.ImageField.height_field]--><tt class="descclassname">ImageField.</tt><tt class="descname">height_field</tt><a class="headerlink" href="#django.db.models.ImageField.height_field" title="Permalink to this definition">¶</a></dt>
<dd>Name of a model field which will be auto-populated with the height of the
image each time the model instance is saved.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ImageField.width_field">
<!--[django.db.models.ImageField.width_field]--><tt class="descclassname">ImageField.</tt><tt class="descname">width_field</tt><a class="headerlink" href="#django.db.models.ImageField.width_field" title="Permalink to this definition">¶</a></dt>
<dd>Name of a model field which will be auto-populated with the width of the
image each time the model instance is saved.</dd></dl>

<p>In addition to the special attributes that are available for <a title="django.db.models.FileField" class="reference internal" href="#django.db.models.FileField"><tt class="xref docutils literal"><span class="pre">FileField</span></tt></a>,
an <a title="django.db.models.ImageField" class="reference internal" href="#django.db.models.ImageField"><tt class="xref docutils literal"><span class="pre">ImageField</span></tt></a> also has <tt class="docutils literal"><span class="pre">File.height</span></tt> and <tt class="docutils literal"><span class="pre">File.width</span></tt> attributes.
See <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/files/#topics-files"><em>Managing files</em></a>.</p>
<p>Requires the <a class="reference external" href="http://www.pythonware.com/products/pil/">Python Imaging Library</a>.</p>
<div class="versionadded">
<span class="title">New in Django 1.0:</span> The <tt class="docutils literal"><span class="pre">max_length</span></tt> argument was added in this version.</div>
<p>By default, <a title="django.db.models.ImageField" class="reference internal" href="#django.db.models.ImageField"><tt class="xref docutils literal"><span class="pre">ImageField</span></tt></a> instances are
created as <tt class="docutils literal"><span class="pre">varchar(100)</span></tt> columns in your database. As with other fields, you
can change the maximum length using the <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> argument.</p>
</div>
<div class="section" id="s-integerfield">
<span id="integerfield"></span><h3><tt class="docutils literal"><span class="pre">IntegerField</span></tt><a class="headerlink" href="#integerfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.IntegerField">
<!--[django.db.models.IntegerField]-->class <tt class="descname">IntegerField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.IntegerField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>An integer. The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a
single-line input).</p>
</div>
<div class="section" id="s-ipaddressfield">
<span id="ipaddressfield"></span><h3><tt class="docutils literal"><span class="pre">IPAddressField</span></tt><a class="headerlink" href="#ipaddressfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.IPAddressField">
<!--[django.db.models.IPAddressField]-->class <tt class="descname">IPAddressField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.IPAddressField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>An IP address, in string format (e.g. "192.0.2.30"). The admin represents this
as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a single-line input).</p>
</div>
<div class="section" id="s-nullbooleanfield">
<span id="nullbooleanfield"></span><h3><tt class="docutils literal"><span class="pre">NullBooleanField</span></tt><a class="headerlink" href="#nullbooleanfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.NullBooleanField">
<!--[django.db.models.NullBooleanField]-->class <tt class="descname">NullBooleanField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.NullBooleanField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like a <a title="django.db.models.BooleanField" class="reference internal" href="#django.db.models.BooleanField"><tt class="xref docutils literal"><span class="pre">BooleanField</span></tt></a>, but allows <tt class="docutils literal"><span class="pre">NULL</span></tt> as one of the options. Use
this instead of a <a title="django.db.models.BooleanField" class="reference internal" href="#django.db.models.BooleanField"><tt class="xref docutils literal"><span class="pre">BooleanField</span></tt></a> with <tt class="docutils literal"><span class="pre">null=True</span></tt>. The admin represents
this as a <tt class="docutils literal"><span class="pre">&lt;select&gt;</span></tt> box with "Unknown", "Yes" and "No" choices.</p>
</div>
<div class="section" id="s-positiveintegerfield">
<span id="positiveintegerfield"></span><h3><tt class="docutils literal"><span class="pre">PositiveIntegerField</span></tt><a class="headerlink" href="#positiveintegerfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.PositiveIntegerField">
<!--[django.db.models.PositiveIntegerField]-->class <tt class="descname">PositiveIntegerField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.PositiveIntegerField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like an <a title="django.db.models.IntegerField" class="reference internal" href="#django.db.models.IntegerField"><tt class="xref docutils literal"><span class="pre">IntegerField</span></tt></a>, but must be positive.</p>
</div>
<div class="section" id="s-positivesmallintegerfield">
<span id="positivesmallintegerfield"></span><h3><tt class="docutils literal"><span class="pre">PositiveSmallIntegerField</span></tt><a class="headerlink" href="#positivesmallintegerfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.PositiveSmallIntegerField">
<!--[django.db.models.PositiveSmallIntegerField]-->class <tt class="descname">PositiveSmallIntegerField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.PositiveSmallIntegerField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like a <a title="django.db.models.PositiveIntegerField" class="reference internal" href="#django.db.models.PositiveIntegerField"><tt class="xref docutils literal"><span class="pre">PositiveIntegerField</span></tt></a>, but only allows values under a certain
(database-dependent) point.</p>
</div>
<div class="section" id="s-slugfield">
<span id="slugfield"></span><h3><tt class="docutils literal"><span class="pre">SlugField</span></tt><a class="headerlink" href="#slugfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.SlugField">
<!--[django.db.models.SlugField]-->class <tt class="descname">SlugField</tt>(<span class="optional">[</span><em>max_length=50</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.SlugField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p><a class="reference external" href="http://docs.djangoproject.com/en/1.0/glossary/#term-slug"><em>Slug</em></a> is a newspaper term. A slug is a short label for something,
containing only letters, numbers, underscores or hyphens. They're generally used
in URLs.</p>
<p>Like a CharField, you can specify <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> (read the note
about database portability and <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> in that section,
too). If <a title="django.db.models.CharField.max_length" class="reference internal" href="#django.db.models.CharField.max_length"><tt class="xref docutils literal"><span class="pre">max_length</span></tt></a> is not specified, Django will use a
default length of 50.</p>
<p>Implies setting <a title="django.db.models.Field.db_index" class="reference internal" href="#django.db.models.Field.db_index"><tt class="xref docutils literal"><span class="pre">Field.db_index</span></tt></a> to <tt class="xref docutils literal"><span class="pre">True</span></tt>.</p>
<p>It is often useful to automatically prepopulate a SlugField based on the value
of some other value.  You can do this automatically in the admin using
<a title="django.contrib.admin.ModelAdmin.prepopulated_fields" class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.prepopulated_fields"><tt class="xref docutils literal"><span class="pre">prepopulated_fields</span></tt></a>.</p>
</div>
<div class="section" id="s-smallintegerfield">
<span id="smallintegerfield"></span><h3><tt class="docutils literal"><span class="pre">SmallIntegerField</span></tt><a class="headerlink" href="#smallintegerfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.SmallIntegerField">
<!--[django.db.models.SmallIntegerField]-->class <tt class="descname">SmallIntegerField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.SmallIntegerField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Like an <a title="django.db.models.IntegerField" class="reference internal" href="#django.db.models.IntegerField"><tt class="xref docutils literal"><span class="pre">IntegerField</span></tt></a>, but only allows values under a certain
(database-dependent) point.</p>
</div>
<div class="section" id="s-textfield">
<span id="textfield"></span><h3><tt class="docutils literal"><span class="pre">TextField</span></tt><a class="headerlink" href="#textfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.TextField">
<!--[django.db.models.TextField]-->class <tt class="descname">TextField</tt>(<span class="optional">[</span><em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.TextField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A large text field. The admin represents this as a <tt class="docutils literal"><span class="pre">&lt;textarea&gt;</span></tt> (a multi-line
input).</p>
<div class="admonition-mysql-users admonition">
<p class="first admonition-title">MySQL users</p>
<p class="last">If you are using this field with MySQLdb 1.2.1p2 and the <tt class="docutils literal"><span class="pre">utf8_bin</span></tt>
collation (which is <em>not</em> the default), there are some issues to be aware
of. Refer to the <a class="reference external" href="http://docs.djangoproject.com/en/1.0/ref/databases/#mysql-collation"><em>MySQL database notes</em></a> for
details.</p>
</div>
</div>
<div class="section" id="s-timefield">
<span id="timefield"></span><h3><tt class="docutils literal"><span class="pre">TimeField</span></tt><a class="headerlink" href="#timefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.TimeField">
<!--[django.db.models.TimeField]-->class <tt class="descname">TimeField</tt>(<span class="optional">[</span><em>auto_now=False</em>, <em>auto_now_add=False</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.TimeField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A time, represented in Python by a <tt class="docutils literal"><span class="pre">datetime.time</span></tt> instance. Accepts the same
auto-population options as <a title="django.db.models.DateField" class="reference internal" href="#django.db.models.DateField"><tt class="xref docutils literal"><span class="pre">DateField</span></tt></a>.</p>
<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> with some JavaScript
shortcuts.</p>
</div>
<div class="section" id="s-urlfield">
<span id="urlfield"></span><h3><tt class="docutils literal"><span class="pre">URLField</span></tt><a class="headerlink" href="#urlfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.URLField">
<!--[django.db.models.URLField]-->class <tt class="descname">URLField</tt>(<span class="optional">[</span><em>verify_exists=True</em>, <em>max_length=200</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.URLField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A <a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> for a URL. Has one extra optional argument:</p>
<dl class="attribute">
<dt id="django.db.models.URLField.verify_exists">
<!--[django.db.models.URLField.verify_exists]--><tt class="descclassname">URLField.</tt><tt class="descname">verify_exists</tt><a class="headerlink" href="#django.db.models.URLField.verify_exists" title="Permalink to this definition">¶</a></dt>
<dd>If <tt class="xref docutils literal"><span class="pre">True</span></tt> (the default), the URL given will be checked for existence
(i.e., the URL actually loads and doesn't give a 404 response). It should
be noted that when using the single-threaded development server, validating
a url being serverd by the same server will hang.
This should not be a problem for multithreaded servers.</dd></dl>

<p>The admin represents this as an <tt class="docutils literal"><span class="pre">&lt;input</span> <span class="pre">type="text"&gt;</span></tt> (a single-line input).</p>
<p>Like all <a title="django.db.models.CharField" class="reference internal" href="#django.db.models.CharField"><tt class="xref docutils literal"><span class="pre">CharField</span></tt></a> subclasses, <a title="django.db.models.URLField" class="reference internal" href="#django.db.models.URLField"><tt class="xref docutils literal"><span class="pre">URLField</span></tt></a> takes the optional
<tt class="xref docutils literal"><span class="pre">max_length</span></tt>, a default of 200 is used.</p>
</div>
<div class="section" id="s-xmlfield">
<span id="xmlfield"></span><h3><tt class="docutils literal"><span class="pre">XMLField</span></tt><a class="headerlink" href="#xmlfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.XMLField">
<!--[django.db.models.XMLField]-->class <tt class="descname">XMLField</tt>(<em>schema_path=None</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.XMLField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A <a title="django.db.models.TextField" class="reference internal" href="#django.db.models.TextField"><tt class="xref docutils literal"><span class="pre">TextField</span></tt></a> that checks that the value is valid XML that matches a
given schema. Takes one required argument:</p>
<dl class="attribute">
<dt id="django.db.models.schema_path">
<!--[django.db.models.schema_path]--><tt class="descname">schema_path</tt><a class="headerlink" href="#django.db.models.schema_path" title="Permalink to this definition">¶</a></dt>
<dd>The filesystem path to a <a class="reference external" href="http://www.relaxng.org/">RelaxNG</a> schema against which to validate the
field.</dd></dl>

</div>
</div>
<div class="section" id="s-module-django.db.models.fields.related">
<span id="module-django.db.models.fields.related"></span><h2>Relationship fields<a class="headerlink" href="#module-django.db.models.fields.related" title="Permalink to this headline">¶</a></h2>
<p>Django also defines a set of fields that represent relations.</p>
<div class="section" id="s-foreignkey">
<span id="s-ref-foreignkey"></span><span id="foreignkey"></span><span id="ref-foreignkey"></span><h3><tt class="docutils literal"><span class="pre">ForeignKey</span></tt><a class="headerlink" href="#foreignkey" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.ForeignKey">
<!--[django.db.models.ForeignKey]-->class <tt class="descname">ForeignKey</tt>(<em>othermodel</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.ForeignKey" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A many-to-one relationship. Requires a positional argument: the class to which
the model is related.</p>
<p id="recursive-relationships">To create a recursive relationship -- an object that has a many-to-one
relationship with itself -- use <tt class="docutils literal"><span class="pre">models.ForeignKey('self')</span></tt>.</p>
<p id="lazy-relationships">If you need to create a relationship on a model that has not yet been defined,
you can use the name of the model, rather than the model object itself:</p>
<div class="highlight-python"><pre>class Car(models.Model):
    manufacturer = models.ForeignKey('Manufacturer')
    # ...

class Manufacturer(models.Model):
    # ...</pre>
</div>
<p>Note, however, that this only refers to models in the same <tt class="docutils literal"><span class="pre">models.py</span></tt> file --
you cannot use a string to reference a model defined in another application or
imported from elsewhere.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.0:</span> Refering models in other applications must include the application label.</div>
<p>To refer to models defined in another
application, you must instead explicitly specify the application label. For
example, if the <tt class="docutils literal"><span class="pre">Manufacturer</span></tt> model above is defined in another application
called <tt class="docutils literal"><span class="pre">production</span></tt>, you'd need to use:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Car</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">manufacturer</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="s">'production.Manufacturer'</span><span class="p">)</span>
</pre></div>
</div>
<p>Behind the scenes, Django appends <tt class="docutils literal"><span class="pre">"_id"</span></tt> to the field name to create its
database column name. In the above example, the database table for the <tt class="docutils literal"><span class="pre">Car</span></tt>
model will have a <tt class="docutils literal"><span class="pre">manufacturer_id</span></tt> column. (You can change this explicitly by
specifying <a title="django.db.models.Field.db_column" class="reference internal" href="#django.db.models.Field.db_column"><tt class="xref docutils literal"><span class="pre">db_column</span></tt></a>) However, your code should never have to
deal with the database column name, unless you write custom SQL. You'll always
deal with the field names of your model object.</p>
<p id="foreign-key-arguments"><a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a> accepts an extra set of arguments -- all optional -- that
define the details of how the relation works.</p>
<dl class="attribute">
<dt id="django.db.models.ForeignKey.limit_choices_to">
<!--[django.db.models.ForeignKey.limit_choices_to]--><tt class="descclassname">ForeignKey.</tt><tt class="descname">limit_choices_to</tt><a class="headerlink" href="#django.db.models.ForeignKey.limit_choices_to" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary of lookup arguments and values (see <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/queries/#topics-db-queries"><em>Making queries</em></a>)
that limit the available admin choices for this object. Use this with
functions from the Python <tt class="docutils literal"><span class="pre">datetime</span></tt> module to limit choices of objects by
date. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">limit_choices_to</span> <span class="o">=</span> <span class="p">{</span><span class="s">'pub_date__lte'</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">}</span>
</pre></div>
</div>
<p>only allows the choice of related objects with a <tt class="docutils literal"><span class="pre">pub_date</span></tt> before the
current date/time to be chosen.</p>
<p>Instead of a dictionary this can also be a <tt class="xref docutils literal"><span class="pre">Q</span></tt>
object (an object with a <tt class="xref docutils literal"><span class="pre">get_sql()</span></tt> method) for more complex queries.</p>
<p><tt class="docutils literal"><span class="pre">limit_choices_to</span></tt> has no effect on the inline FormSets that are created
to display related objects in the admin.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ForeignKey.related_name">
<!--[django.db.models.ForeignKey.related_name]--><tt class="descclassname">ForeignKey.</tt><tt class="descname">related_name</tt><a class="headerlink" href="#django.db.models.ForeignKey.related_name" title="Permalink to this definition">¶</a></dt>
<dd>The name to use for the relation from the related object back to this one.
See the <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/queries/#backwards-related-objects"><em>related objects documentation</em></a> for
a full explanation and example. Note that you must set this value
when defining relations on <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#abstract-base-classes"><em>abstract models</em></a>; and when you do so
<a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#abstract-related-name"><em>some special syntax</em></a> is available.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ForeignKey.to_field">
<!--[django.db.models.ForeignKey.to_field]--><tt class="descclassname">ForeignKey.</tt><tt class="descname">to_field</tt><a class="headerlink" href="#django.db.models.ForeignKey.to_field" title="Permalink to this definition">¶</a></dt>
<dd>The field on the related object that the relation is to. By default, Django
uses the primary key of the related object.</dd></dl>

</div>
<div class="section" id="s-manytomanyfield">
<span id="s-ref-manytomany"></span><span id="manytomanyfield"></span><span id="ref-manytomany"></span><h3><tt class="docutils literal"><span class="pre">ManyToManyField</span></tt><a class="headerlink" href="#manytomanyfield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.ManyToManyField">
<!--[django.db.models.ManyToManyField]-->class <tt class="descname">ManyToManyField</tt>(<em>othermodel</em><span class="optional">[</span>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.ManyToManyField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A many-to-many relationship. Requires a positional argument: the class to which
the model is related. This works exactly the same as it does for
<a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a>, including all the options regarding <a class="reference internal" href="#recursive-relationships"><em>recursive</em></a> and <a class="reference internal" href="#lazy-relationships"><em>lazy</em></a> relationships.</p>
<p>Behind the scenes, Django creates an intermediary join table to represent the
many-to-many relationship. By default, this table name is generated using the
names of the two tables being joined. Since some databases don't support table
names above a certain length, these table names will be automatically
truncated to 64 characters and a uniqueness hash will be used. This means you
might see table names like <tt class="docutils literal"><span class="pre">author_books_9cdf4</span></tt>; this is perfectly normal.
You can manually provide the name of the join table using the
<a title="django.db.models.ManyToManyField.db_table" class="reference internal" href="#django.db.models.ManyToManyField.db_table"><tt class="xref docutils literal"><span class="pre">db_table</span></tt></a> option.</p>
<p id="manytomany-arguments"><a title="django.db.models.ManyToManyField" class="reference internal" href="#django.db.models.ManyToManyField"><tt class="xref docutils literal"><span class="pre">ManyToManyField</span></tt></a> accepts an extra set of arguments -- all optional --
that control how the relationship functions.</p>
<dl class="attribute">
<dt id="django.db.models.ManyToManyField.related_name">
<!--[django.db.models.ManyToManyField.related_name]--><tt class="descclassname">ManyToManyField.</tt><tt class="descname">related_name</tt><a class="headerlink" href="#django.db.models.ManyToManyField.related_name" title="Permalink to this definition">¶</a></dt>
<dd>Same as <a title="django.db.models.ForeignKey.related_name" class="reference internal" href="#django.db.models.ForeignKey.related_name"><tt class="xref docutils literal"><span class="pre">ForeignKey.related_name</span></tt></a>.</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ManyToManyField.limit_choices_to">
<!--[django.db.models.ManyToManyField.limit_choices_to]--><tt class="descclassname">ManyToManyField.</tt><tt class="descname">limit_choices_to</tt><a class="headerlink" href="#django.db.models.ManyToManyField.limit_choices_to" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a title="django.db.models.ForeignKey.limit_choices_to" class="reference internal" href="#django.db.models.ForeignKey.limit_choices_to"><tt class="xref docutils literal"><span class="pre">ForeignKey.limit_choices_to</span></tt></a>.</p>
<p><tt class="docutils literal"><span class="pre">limit_choices_to</span></tt> has no effect when used on a <tt class="docutils literal"><span class="pre">ManyToManyField</span></tt> with a
custom intermediate table specified using the
<a title="django.db.models.ManyToManyField.through" class="reference internal" href="#django.db.models.ManyToManyField.through"><tt class="xref docutils literal"><span class="pre">through</span></tt></a> paramter.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ManyToManyField.symmetrical">
<!--[django.db.models.ManyToManyField.symmetrical]--><tt class="descclassname">ManyToManyField.</tt><tt class="descname">symmetrical</tt><a class="headerlink" href="#django.db.models.ManyToManyField.symmetrical" title="Permalink to this definition">¶</a></dt>
<dd><p>Only used in the definition of ManyToManyFields on self. Consider the
following model:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Person</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">friends</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ManyToManyField</span><span class="p">(</span><span class="s">"self"</span><span class="p">)</span>
</pre></div>
</div>
<p>When Django processes this model, it identifies that it has a
<a title="django.db.models.ManyToManyField" class="reference internal" href="#django.db.models.ManyToManyField"><tt class="xref docutils literal"><span class="pre">ManyToManyField</span></tt></a> on itself, and as a result, it doesn't add a
<tt class="docutils literal"><span class="pre">person_set</span></tt> attribute to the <tt class="docutils literal"><span class="pre">Person</span></tt> class. Instead, the
<a title="django.db.models.ManyToManyField" class="reference internal" href="#django.db.models.ManyToManyField"><tt class="xref docutils literal"><span class="pre">ManyToManyField</span></tt></a> is assumed to be symmetrical -- that is, if I am
your friend, then you are my friend.</p>
<p>If you do not want symmetry in many-to-many relationships with <tt class="docutils literal"><span class="pre">self</span></tt>, set
<a title="django.db.models.ManyToManyField.symmetrical" class="reference internal" href="#django.db.models.ManyToManyField.symmetrical"><tt class="xref docutils literal"><span class="pre">symmetrical</span></tt></a> to <tt class="xref docutils literal"><span class="pre">False</span></tt>. This will force Django to
add the descriptor for the reverse relationship, allowing
<a title="django.db.models.ManyToManyField" class="reference internal" href="#django.db.models.ManyToManyField"><tt class="xref docutils literal"><span class="pre">ManyToManyField</span></tt></a> relationships to be non-symmetrical.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ManyToManyField.through">
<!--[django.db.models.ManyToManyField.through]--><tt class="descclassname">ManyToManyField.</tt><tt class="descname">through</tt><a class="headerlink" href="#django.db.models.ManyToManyField.through" title="Permalink to this definition">¶</a></dt>
<dd><p>Django will automatically generate a table to manage many-to-many
relationships. However, if you want to manually specify the intermediary
table, you can use the <a title="django.db.models.ManyToManyField.through" class="reference internal" href="#django.db.models.ManyToManyField.through"><tt class="xref docutils literal"><span class="pre">through</span></tt></a> option to specify
the Django model that represents the intermediate table that you want to
use.</p>
<p>The most common use for this option is when you want to associate
<a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#intermediary-manytomany"><em>extra data with a many-to-many relationship</em></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.db.models.ManyToManyField.db_table">
<!--[django.db.models.ManyToManyField.db_table]--><tt class="descclassname">ManyToManyField.</tt><tt class="descname">db_table</tt><a class="headerlink" href="#django.db.models.ManyToManyField.db_table" title="Permalink to this definition">¶</a></dt>
<dd>The name of the table to create for storing the many-to-many data. If this
is not provided, Django will assume a default name based upon the names of
the two tables being joined.</dd></dl>

</div>
<div class="section" id="s-onetoonefield">
<span id="s-ref-onetoone"></span><span id="onetoonefield"></span><span id="ref-onetoone"></span><h3><tt class="docutils literal"><span class="pre">OneToOneField</span></tt><a class="headerlink" href="#onetoonefield" title="Permalink to this headline">¶</a></h3>
<dl class="class">
<dt id="django.db.models.OneToOneField">
<!--[django.db.models.OneToOneField]-->class <tt class="descname">OneToOneField</tt>(<em>othermodel</em><span class="optional">[</span>, <em>parent_link=False</em>, <em>**options</em><span class="optional">]</span>)<a class="headerlink" href="#django.db.models.OneToOneField" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>A one-to-one relationship. Conceptually, this is similar to a
<a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a> with <a title="django.db.models.Field.unique" class="reference internal" href="#django.db.models.Field.unique"><tt class="xref docutils literal"><span class="pre">unique=True</span></tt></a>, but the
"reverse" side of the relation will directly return a single object.</p>
<p>This is most useful as the primary key of a model which "extends"
another model in some way; <a class="reference external" href="http://docs.djangoproject.com/en/1.0/topics/db/models/#multi-table-inheritance"><em>Multi-table inheritance</em></a> is
implemented by adding an implicit one-to-one relation from the child
model to the parent model, for example.</p>
<p>One positional argument is required: the class to which the model will be
related. This works exactly the same as it does for <a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a>,
including all the options regarding <a class="reference internal" href="#recursive-relationships"><em>recursive</em></a>
and <a class="reference internal" href="#lazy-relationships"><em>lazy</em></a> relationships.</p>
<p id="onetoone-arguments">Additionally, <tt class="docutils literal"><span class="pre">OneToOneField</span></tt> accepts all of the extra arguments
accepted by <a title="django.db.models.ForeignKey" class="reference internal" href="#django.db.models.ForeignKey"><tt class="xref docutils literal"><span class="pre">ForeignKey</span></tt></a>, plus one extra argument:</p>
<dl class="attribute">
<dt id="django.db.models.OneToOneField.parent_link">
<!--[django.db.models.OneToOneField.parent_link]--><tt class="descclassname">OneToOneField.</tt><tt class="descname">parent_link</tt><a class="headerlink" href="#django.db.models.OneToOneField.parent_link" title="Permalink to this definition">¶</a></dt>
<dd>When <tt class="xref docutils literal"><span class="pre">True</span></tt> and used in a model which inherits from another
(concrete) model, indicates that this field should be used as the
link back to the parent class, rather than the extra
<tt class="docutils literal"><span class="pre">OneToOneField</span></tt> which would normally be implicitly created by
subclassing.</dd></dl>

</div>
</div>
</div>



<div id="content-secondary">
  <h2 id="comments">Questions/Feedback</h2>
  <p>Having trouble? We'd like to help!</p>
  <ul>
    <li>
      Try the <a href="http://docs.djangoproject.com/en/dev/faq/">FAQ</a> — it's got answers to many common
      questions.
    </li>
    <li>
      Search for information in the <a href="http://groups.google.com/group/django-users/">archives of the
      django-users mailing list</a>, or <a href="http://groups.google.com/group/django-users/">post a question</a>.
    </li>
    <li>
      Ask a question in the <a href="irc://irc.freenode.net/">#django IRC
      channel</a>, or search the <a href="http://oebfare.com/logger/django/">IRC
      logs</a> to see if its been asked before.
    </li>
    <li>
      If you notice errors with this documentation, please <a href="http://code.djangoproject.com/simpleticket?component=Documentation">
      open a ticket</a> and let us know! Please only use the ticket tracker for
      criticisms and improvements on the docs. For tech support, use the
      resources above.
    </li>
  </ul>
</div>

		</div>
		<!-- END #content-main -->
		<div id="content-related" class="sidebar">
		
  
    <h2>Contents</h2>
    
      <ul>
<li><a class="reference external" href="">Model field reference</a><ul>
<li><a class="reference external" href="#field-options">Field options</a><ul>
<li><a class="reference external" href="#null"><tt class="docutils literal"><span class="pre">null</span></tt></a></li>
<li><a class="reference external" href="#blank"><tt class="docutils literal"><span class="pre">blank</span></tt></a></li>
<li><a class="reference external" href="#choices"><tt class="docutils literal"><span class="pre">choices</span></tt></a></li>
<li><a class="reference external" href="#db-column"><tt class="docutils literal"><span class="pre">db_column</span></tt></a></li>
<li><a class="reference external" href="#db-index"><tt class="docutils literal"><span class="pre">db_index</span></tt></a></li>
<li><a class="reference external" href="#db-tablespace"><tt class="docutils literal"><span class="pre">db_tablespace</span></tt></a></li>
<li><a class="reference external" href="#default"><tt class="docutils literal"><span class="pre">default</span></tt></a></li>
<li><a class="reference external" href="#editable"><tt class="docutils literal"><span class="pre">editable</span></tt></a></li>
<li><a class="reference external" href="#help-text"><tt class="docutils literal"><span class="pre">help_text</span></tt></a></li>
<li><a class="reference external" href="#primary-key"><tt class="docutils literal"><span class="pre">primary_key</span></tt></a></li>
<li><a class="reference external" href="#unique"><tt class="docutils literal"><span class="pre">unique</span></tt></a></li>
<li><a class="reference external" href="#unique-for-date"><tt class="docutils literal"><span class="pre">unique_for_date</span></tt></a></li>
<li><a class="reference external" href="#unique-for-month"><tt class="docutils literal"><span class="pre">unique_for_month</span></tt></a></li>
<li><a class="reference external" href="#unique-for-year"><tt class="docutils literal"><span class="pre">unique_for_year</span></tt></a></li>
<li><a class="reference external" href="#verbose-name"><tt class="docutils literal"><span class="pre">verbose_name</span></tt></a></li>
</ul>
</li>
<li><a class="reference external" href="#field-types">Field types</a><ul>
<li><a class="reference external" href="#autofield"><tt class="docutils literal"><span class="pre">AutoField</span></tt></a></li>
<li><a class="reference external" href="#booleanfield"><tt class="docutils literal"><span class="pre">BooleanField</span></tt></a></li>
<li><a class="reference external" href="#charfield"><tt class="docutils literal"><span class="pre">CharField</span></tt></a></li>
<li><a class="reference external" href="#commaseparatedintegerfield"><tt class="docutils literal"><span class="pre">CommaSeparatedIntegerField</span></tt></a></li>
<li><a class="reference external" href="#datefield"><tt class="docutils literal"><span class="pre">DateField</span></tt></a></li>
<li><a class="reference external" href="#datetimefield"><tt class="docutils literal"><span class="pre">DateTimeField</span></tt></a></li>
<li><a class="reference external" href="#decimalfield"><tt class="docutils literal"><span class="pre">DecimalField</span></tt></a></li>
<li><a class="reference external" href="#emailfield"><tt class="docutils literal"><span class="pre">EmailField</span></tt></a></li>
<li><a class="reference external" href="#filefield"><tt class="docutils literal"><span class="pre">FileField</span></tt></a></li>
<li><a class="reference external" href="#filepathfield"><tt class="docutils literal"><span class="pre">FilePathField</span></tt></a></li>
<li><a class="reference external" href="#floatfield"><tt class="docutils literal"><span class="pre">FloatField</span></tt></a></li>
<li><a class="reference external" href="#imagefield"><tt class="docutils literal"><span class="pre">ImageField</span></tt></a></li>
<li><a class="reference external" href="#integerfield"><tt class="docutils literal"><span class="pre">IntegerField</span></tt></a></li>
<li><a class="reference external" href="#ipaddressfield"><tt class="docutils literal"><span class="pre">IPAddressField</span></tt></a></li>
<li><a class="reference external" href="#nullbooleanfield"><tt class="docutils literal"><span class="pre">NullBooleanField</span></tt></a></li>
<li><a class="reference external" href="#positiveintegerfield"><tt class="docutils literal"><span class="pre">PositiveIntegerField</span></tt></a></li>
<li><a class="reference external" href="#positivesmallintegerfield"><tt class="docutils literal"><span class="pre">PositiveSmallIntegerField</span></tt></a></li>
<li><a class="reference external" href="#slugfield"><tt class="docutils literal"><span class="pre">SlugField</span></tt></a></li>
<li><a class="reference external" href="#smallintegerfield"><tt class="docutils literal"><span class="pre">SmallIntegerField</span></tt></a></li>
<li><a class="reference external" href="#textfield"><tt class="docutils literal"><span class="pre">TextField</span></tt></a></li>
<li><a class="reference external" href="#timefield"><tt class="docutils literal"><span class="pre">TimeField</span></tt></a></li>
<li><a class="reference external" href="#urlfield"><tt class="docutils literal"><span class="pre">URLField</span></tt></a></li>
<li><a class="reference external" href="#xmlfield"><tt class="docutils literal"><span class="pre">XMLField</span></tt></a></li>
</ul>
</li>
<li><a class="reference external" href="#module-django.db.models.fields.related">Relationship fields</a><ul>
<li><a class="reference external" href="#foreignkey"><tt class="docutils literal"><span class="pre">ForeignKey</span></tt></a></li>
<li><a class="reference external" href="#manytomanyfield"><tt class="docutils literal"><span class="pre">ManyToManyField</span></tt></a></li>
<li><a class="reference external" href="#onetoonefield"><tt class="docutils literal"><span class="pre">OneToOneField</span></tt></a></li>
</ul>
</li>
</ul>
</li>
</ul>

    
  
  
  
    <h2>Search</h2>
    
    <form action="/en/1.0/search/" id="search" class="search">
  <div>
    <input name="cx" value="009763561546736975936:e88ek0eurf4" type="hidden">
    <input name="cof" value="FORID:11" type="hidden">
    <input name="ie" value="UTF-8" type="hidden">
    <input name="hl" value="" type="hidden">
    <input style="background: rgb(255, 255, 255) url(http://www.google.com/coop/intl/en/images/google_custom_search_watermark.gif) no-repeat scroll left center; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" id="id_search_q" class="query" name="q" type="text">
    <input name="sa" class="submit" value="Search" type="submit">
    <ul>
<li><label for="id_search_as_q_0"><input checked="checked" id="id_search_as_q_0" value="more:dev_docs" name="as_q" type="radio"> Latest</label></li>
<li><label for="id_search_as_q_1"><input id="id_search_as_q_1" value="more:1.0_docs" name="as_q" type="radio"> 1.0</label></li>
<li><label for="id_search_as_q_2"><input id="id_search_as_q_2" value="more:0.96_docs" name="as_q" type="radio"> 0.96</label></li>
<li><label for="id_search_as_q_3"><input id="id_search_as_q_3" value="more:all_docs" name="as_q" type="radio"> All</label></li>
</ul>
  </div>
</form>
<script type="text/javascript" src="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/brand.html"></script>
  
  
  
    <h2>Browse</h2>
    <ul>
      
        
          <li>Prev: <a href="http://docs.djangoproject.com/en/1.0/ref/models/">Models</a></li>
        
        
          <li>Next: <a href="http://docs.djangoproject.com/en/1.0/ref/models/relations/">Related objects reference</a></li>
        
        <li><a href="http://docs.djangoproject.com/en/1.0/contents/">Table of contents</a></li>
        
          <li><a href="http://docs.djangoproject.com/en/1.0/genindex/">General Index</a></li>
        
          <li><a href="http://docs.djangoproject.com/en/1.0/modindex/">Global Module Index</a></li>
        
      
    </ul>
  
  
  
    <h2>You are here:</h2>
    <ul>
      
        <li>
          <a href="http://docs.djangoproject.com/en/1.0/">Django 1.0 documentation</a>
          
            <ul><li><a href="http://docs.djangoproject.com/en/1.0/ref/">API Reference</a>
          
            <ul><li><a href="http://docs.djangoproject.com/en/1.0/ref/models/">Models</a>
          
          <ul><li>Model field reference</li></ul>
          </li></ul></li></ul>
        </li>
      
    </ul>
  
  
  
    <h3>Last update:</h3>
    <div>May 23, 2009, 8:15 a.m. (<a href="http://www.timeanddate.com/worldclock/city.html?n=64">CDT</a>)</div>
  

		</div>
		<!-- END #content-related -->

		</div>
		<!-- END #content -->
		<div id="footer">
			<p>© 2005-2009 <a href="http://www.djangoproject.com/foundation/">Django Software Foundation</a> unless otherwise noted. Django is a registered trademark of the Django Software Foundation. 
			Hosting graciously provided by <a href="http://mediatemple.net/">
			<img style="vertical-align: middle; position: relative; top: -1px;" src="Django%20%7C%20Model%20field%20reference%20%7C%20Django%20Documentation_files/mt.png" alt="media temple"></a>
			</p>
		</div>
		<!-- END #footer -->
	</div>
	<!-- END #container -->
	</body></html>